package com.swq.java.code.chapter15.code11;

import java.util.*;

public class CollectionsTester {
    public static void main(String args[]) {
        List<String> list = Arrays.asList(new String[]{"Tom", "Jack", "Linda", "Rose"});
        Collections.sort(list); //把List中的元素自然排序
        System.out.println(Collections.max(list));  //打印Tom
        System.out.println(Collections.min(list));  //打印Jack

        System.out.println(Collections.binarySearch(list, "Tom"));  //打印3
        System.out.println(list);
        System.out.println(Arrays.toString(list.toArray()));  //打印[Jack,Linda,Rose,Tom]
        Collections.shuffle(list);  //重新随机调整List中元素的位置
        System.out.println(Arrays.toString(list.toArray()));  //可能打印[Linda,Tom,Jack,Rose]
        Collections.shuffle(list);  //重新随机调整List中元素的位置
        System.out.println(Arrays.toString(list.toArray()));  //可能打印[Jack, Tom, Rose, Linda]
    }
}